package com.ruoyi.demo.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.demo.domain.SakuraHonor;
import com.ruoyi.demo.service.ISakuraHonorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 个人荣誉Controller
 * 
 * @author 蓝鲸
 * @date 2024-08-12
 */
@RestController
@RequestMapping("/demo/honor")
public class SakuraHonorController extends BaseController
{
    @Autowired
    private ISakuraHonorService sakuraHonorService;

    /**
     * 查询个人荣誉列表
     */
    @PreAuthorize("@ss.hasPermi('demo:honor:list')")
    @GetMapping("/list")
    public TableDataInfo list(SakuraHonor sakuraHonor)
    {
        startPage();
        List<SakuraHonor> list = sakuraHonorService.selectSakuraHonorList(sakuraHonor);
        return getDataTable(list);
    }

    /**
     * 导出个人荣誉列表
     */
    @PreAuthorize("@ss.hasPermi('demo:honor:export')")
    @Log(title = "个人荣誉", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SakuraHonor sakuraHonor)
    {
        List<SakuraHonor> list = sakuraHonorService.selectSakuraHonorList(sakuraHonor);
        ExcelUtil<SakuraHonor> util = new ExcelUtil<SakuraHonor>(SakuraHonor.class);
        util.exportExcel(response, list, "个人荣誉数据");
    }

    /**
     * 获取个人荣誉详细信息
     */
    @PreAuthorize("@ss.hasPermi('demo:honor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sakuraHonorService.selectSakuraHonorById(id));
    }

    /**
     * 新增个人荣誉
     */
    @PreAuthorize("@ss.hasPermi('demo:honor:add')")
    @Log(title = "个人荣誉", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SakuraHonor sakuraHonor)
    {
        return toAjax(sakuraHonorService.insertSakuraHonor(sakuraHonor));
    }

    /**
     * 修改个人荣誉
     */
    @PreAuthorize("@ss.hasPermi('demo:honor:edit')")
    @Log(title = "个人荣誉", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SakuraHonor sakuraHonor)
    {
        return toAjax(sakuraHonorService.updateSakuraHonor(sakuraHonor));
    }

    /**
     * 删除个人荣誉
     */
    @PreAuthorize("@ss.hasPermi('demo:honor:remove')")
    @Log(title = "个人荣誉", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sakuraHonorService.deleteSakuraHonorByIds(ids));
    }
}
